package com.bw.usercenter.ui.customview

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.Gravity
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.bw.mvpcore.glideload.GlidImg
import com.bw.usercenter.R

class MyHomeCustomView : LinearLayout {
    constructor(context: Context?) : super(context) {
        initfun()
    }
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
        initfun()
    }
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context,
        attrs,
        defStyleAttr) {
        initfun()
    }
    constructor(
        context: Context?,
        attrs: AttributeSet?,
        defStyleAttr: Int,
        defStyleRes: Int
    ) : super(context, attrs, defStyleAttr, defStyleRes) {
        initfun()
    }

    private fun initfun(){
        orientation = VERTICAL
        gravity = Gravity.CENTER


        var textmoney:TextView = TextView(context)
        textmoney.setText("￥9999")
        textmoney.textSize = 14f
        textmoney.gravity  = Gravity.CENTER

        var textmoneythru:TextView = TextView(context)
        textmoneythru.setText("￥19999")
        textmoneythru.textSize = 12f
        textmoneythru.setTextColor(Color.parseColor("#787878"))
        textmoneythru.gravity = Gravity.CENTER
        //删除线 抗锯齿
        textmoneythru.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
        textmoneythru.paint.isAntiAlias = true

        var img: ImageView = ImageView(context)
        GlidImg.glidImg.getDrawableimg(context,img,R.drawable.dd)
        img.layoutParams = LayoutParams(100,150)

        addView(img)
        addView(textmoney)
        addView(textmoneythru)
    }
}